/*
 * Students:
 * Massimiliano Rango - 610826
 * Martina Benedetto - 610962
 * 
 * A.A 2011/2012
 * 
 */ 

/**
 *
 * This class represents the position of a Node. Each Position consists of two
 * float coordinates, x and y, where: 0 <= x <= 1 and 0 <= y <= 1, beacause the
 * area where the Nodes are located is unit-squared.
 * 
 * @version 1.0 27 Dec 2011
 * @author Martina Benedetto 
 *
 */

public class Position {
	
	private float m_x;
	private float m_y;
	
	public Position(float x, float y) {
		m_x = x;
		m_y = y;
	}
	
	public boolean equals(Position p) {
		return (p.getXPosition() == m_x) && (p.getYPosition() == m_y);
	}
	
	/**
	 * 
	 * @param to is the Position from which we want to calculate the distance
	 * from the current Node
	 * @return the distance
	 */
	public double distanceFrom(Position to) {
		return Math.sqrt(Math.pow((to.getXPosition() - m_x), 2) + Math.pow((to.getYPosition() - m_y), 2));
	}
	
	public String toString() {
		return m_x + "," + m_y;
	}
	
	public float getXPosition() {
		return m_x;
	}
	
	public float getYPosition() {
		return m_y;
	}
}